// 导入二次封装axios
import koi from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LIST_PAGE = "/blog/blogArticle/listPage",
  DELETE = "/blog/blogArticle/deleteById",
  BATCH_DELETE = "/blog/blogArticle/batchDelete",
  UPDATE_STATUS = "/blog/blogArticle/updateStatus",
  GET_SORTED = "/blog/blogArticle/getSorted",
  PUBLISH = "/blog/blogArticle/publish",
  ECHO_BY_ID = "/blog/blogArticle/echoById",
  UPDATE = "/blog/blogArticle/update",
  PREVIEW = "/blog/blogArticle/preview",
  LIST_LIBRARY_CHOOSE_ARTICLE_PAGE = "/blog/blogArticle/listLibraryChooseArticlePage"
}

// 多条件分页查询
export const listPage = (params: any) => {
  return koi.get(API.LIST_PAGE, params);
};

// 删除
export const deleteById = (id: any) => {
  return koi.post(API.DELETE + "/" + id);
};

// 批量删除
export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, ids);
};

// 修改文章状态、是否推荐、是否热门
export const updateStatus = (id: any, type: any, articleStatus: any) => {
  return koi.post(API.UPDATE_STATUS + "/" + id + "/" + type + "/" + articleStatus);
};

// 获取最新排序
export const getSorted = () => {
  return koi.get(API.GET_SORTED);
};

// 发布文章
export const publish = (data: any) => {
  return koi.post(API.PUBLISH, data);
};

// 根据文章ID进行查询
export const echoById = (id: any) => {
  return koi.get(API.ECHO_BY_ID + "/" + id);
};

// 修改文章
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 预览文章
export const preview = (id: any) => {
  return koi.get(API.PREVIEW + "/" + id);
};

// 博客知识库目录选择文章分页查询
export const listLibraryChooseArticlePage = (params: any) => {
  return koi.get(API.LIST_LIBRARY_CHOOSE_ARTICLE_PAGE, params);
};